library(tidyverse)
library(readstata13)
library(foreign)
library(readxl)
library(writexl)
library(tidyverse)
library(readstata13)
library(foreign)
library(readxl)
library(writexl)
library(lubridate)
rcs_data <- read_xlsx("RepeatedCrossSectional-V3(06182022)_FV.xlsx")
ls(rcs_data)
View(rcs_data)
rcs_data_lim <- rcs_data %>%
select(coddepto:nv_quality_sources)
rcs_data_lim <- rcs_data %>%
select(divipola, year, t_num_camp:nv_quality_sources)
rcs_data_lim <- rcs_data %>%
select(divipola, year, t_num_camp:nv_quality_sources) %>%
dplyr::filter(year > 1984 & year < 2006)
View(rcs_data_lim)
m_data_f <- read_xlsx("/Users/SHSU/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.ResearchAgenda&Pipeline/Project1/StatisticalAnalysis/Ortega(2022)-Chapter5_MasterData(1982-2010).xlsx")
View(m_data_f)
rm(m_data_f)
m_data_f <- read_xlsx("/Users/SHSU/Library/Mobile Documents/com~apple~CloudDocs/Documents/Sam Houston State University/1.1.ResearchAgenda-2023_24/2023-2024/Paper2.1/StatisticalAnalysis/Ortega(2022)-Chapter5_MasterData(1982-2010).xlsx")
rcs_data %>%
group_by(s_strat) %>%
count()
rcs_data_lim <- rcs_data %>%
select(divipola, year, t_num_camp:nv_quality_sources) %>%
dplyr::filter(year > 1984 & year < 2006)
View(rcs_data)
View(rcs_data_lim)
View(rcs_data_lim)
rcs_data_lim <- rcs_data %>%
select(divipola, year, territory_off:t_progov) %>%
dplyr::filter(year > 1984 & year < 2006)
View(rcs_data_lim)
write_xlsx(rcs_data_lim, "Ortega(2024)-ODAW_v1.1.xlsx")
rcs_data <- read_xlsx("Ortega(2024)-ODAW_v1.1.xlsx")
rcs_data_r <- rcs_data %>%
dplyr:filter(t_rebels == 1) %>%
mutate(p_strat = case_when(
protests == 1 | demonstrations == 1 | direct_actions == 1 ~ 1,
protests == 0 & demonstrations == 0 & direct_actions == 0 ~ 0),
s_strat = case_when(
territory_off == 1 | active_terrc == 1 | soc_nc == 1 | pol_nc == 1 |
eco_nc == 1 | soc_int == 1 | pol_int == 1 | eco_int == 1 ~ 1,
territory_off == 0 & active_terrc == 0 & soc_nc == 0 & pol_nc == 0 &
eco_nc == 0 & soc_int == 0 & pol_int == 0 & eco_int == 0 ~ 0),
v_strat = case_when(
ua_civilians == 1 | ua_groups == 1 | terr_control == 1 | clashes == 1 ~ 1,
ua_civilians == 0 & ua_groups == 0 & terr_control == 0 & clashes == 0 ~ 0))
library(tidyverse)
library(readstata13)
library(foreign)
library(readxl)
library(writexl)
rcs_data_r <- rcs_data %>%
dplyr:filter(t_rebels == 1) %>%
mutate(p_strat = case_when(
protests == 1 | demonstrations == 1 | direct_actions == 1 ~ 1,
protests == 0 & demonstrations == 0 & direct_actions == 0 ~ 0),
s_strat = case_when(
territory_off == 1 | active_terrc == 1 | soc_nc == 1 | pol_nc == 1 |
eco_nc == 1 | soc_int == 1 | pol_int == 1 | eco_int == 1 ~ 1,
territory_off == 0 & active_terrc == 0 & soc_nc == 0 & pol_nc == 0 &
eco_nc == 0 & soc_int == 0 & pol_int == 0 & eco_int == 0 ~ 0),
v_strat = case_when(
ua_civilians == 1 | ua_groups == 1 | terr_control == 1 | clashes == 1 ~ 1,
ua_civilians == 0 & ua_groups == 0 & terr_control == 0 & clashes == 0 ~ 0))
rcs_data_r <- rcs_data %>%
dplyr::filter(t_rebels == 1) %>%
mutate(p_strat = case_when(
protests == 1 | demonstrations == 1 | direct_actions == 1 ~ 1,
protests == 0 & demonstrations == 0 & direct_actions == 0 ~ 0),
s_strat = case_when(
territory_off == 1 | active_terrc == 1 | soc_nc == 1 | pol_nc == 1 |
eco_nc == 1 | soc_int == 1 | pol_int == 1 | eco_int == 1 ~ 1,
territory_off == 0 & active_terrc == 0 & soc_nc == 0 & pol_nc == 0 &
eco_nc == 0 & soc_int == 0 & pol_int == 0 & eco_int == 0 ~ 0),
v_strat = case_when(
ua_civilians == 1 | ua_groups == 1 | terr_control == 1 | clashes == 1 ~ 1,
ua_civilians == 0 & ua_groups == 0 & terr_control == 0 & clashes == 0 ~ 0))
rcs_data <- rcs_data %>%
mutate(p_strat = case_when(
protests == 1 | demonstrations == 1 | direct_actions == 1 ~ 1,
protests == 0 & demonstrations == 0 & direct_actions == 0 ~ 0),
s_strat = case_when(
territory_off == 1 | active_terrc == 1 | soc_nc == 1 | pol_nc == 1 |
eco_nc == 1 | soc_int == 1 | pol_int == 1 | eco_int == 1 ~ 1,
territory_off == 0 & active_terrc == 0 & soc_nc == 0 & pol_nc == 0 &
eco_nc == 0 & soc_int == 0 & pol_int == 0 & eco_int == 0 ~ 0),
v_strat = case_when(
ua_civilians == 1 | ua_groups == 1 | terr_control == 1 | clashes == 1 ~ 1,
ua_civilians == 0 & ua_groups == 0 & terr_control == 0 & clashes == 0 ~ 0))
View(rcs_data)
View(rcs_data)
rcs_data <- rcs_data %>%
mutate(cr = case_when(
t_rebels == 1 | r_state == 1 | t_progov ~ 1,
t_rebels == 0 & r_state == 0 & t_progov 0 ~ 0)
rcs_data <- rcs_data %>%
mutate(cr = case_when(
t_rebels == 1 | r_state == 1 | t_progov == 1 ~ 1,
t_rebels == 0 & r_state == 0 & t_progov == 0 ~ 0))
rcs_data <- rcs_data %>%
mutate(cr = case_when(
t_rebels == 1 | t_state == 1 | t_progov == 1 ~ 1,
t_rebels == 0 & t_state == 0 & t_progov == 0 ~ 0))
rcs_data_cr <- rcs_data %>%
dplyr::filter(cr == 1)
vippa <- read.dta13("ViPPA_v1_2.dta")
vippa_mil <- vippa %>%
filter(actor_main == "Paramilitaries")
vippa_mil <- vippa_mil %>%
filter(year < 2006)
vippa_mil %>%
group_by(actor_sub, actor) %>%
count()
vippa_mil_my <- vippa_mil %>%
group_by(mun, year, actor_sub) %>%
summarise(reports = n(), na.rm = TRUE)
w_vippa_mil_my <- spread(vippa_mil_my, actor_sub, reports)
w_vippa_mil_my <- w_vippa_mil_my %>%
dplyr::select(-c(na.rm, presence)) # It does not yield any result
w_vippa_mil_my <- w_vippa_mil_my %>%
rename(mil_gen = "Para. Generic",
soc_cl = "Social cleansing",
indep = "Independent_(310)")
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate_at(vars(mil_gen:indep)
, ~replace_na(., 0))
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate(c_mil_gen = if_else(mil_gen > 1, 1, 0), # This is to maintain the selection criterion of the dataset
d_mil_gen = if_else(mil_gen > 0, 1, 0),
d_AUC = if_else(AUC > 0, 1, 0),
d_ERPAC = if_else(ERPAC > 0, 1, 0),
d_AGC = if_else(AGC > 0, 1, 0),
d_ACC = if_else(ACC > 0, 1, 0),
d_ACCU = if_else(ACCU > 0, 1, 0),
d_soc_cl = if_else(soc_cl > 0, 1, 0),
d_indep = if_else(indep > 0, 1, 0)
)
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate(cr_v3 = case_when( # This is with the criterion!!!
c_mil_gen == 1 & d_AUC == 0 & d_ERPAC == 0 & d_AGC == 0
& d_ACCU == 0 & d_ACC == 0 ~ 1,
d_AUC == 1 | d_ERPAC == 1 | d_AGC == 1 | d_ACCU == 1 |
d_ACC == 1 ~ 0,
TRUE ~ 0))
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate(cr_v2 = case_when(
d_mil_gen == 1 & d_AUC == 0 & d_ERPAC == 0 & d_AGC == 0
& d_ACCU == 0 & d_ACC == 0 ~ 1,
d_AUC == 1 | d_ERPAC == 1 | d_AGC == 1 | d_ACCU == 1 |
d_ACC == 1 ~ 0,
TRUE ~ 0))
w_vippa_mil_my %>%
group_by(cr_v3) %>%
count()
w_vippa_mil_my <- w_vippa_mil_my %>%
rename(divipola = mun)
cdaw_iv <- left_join(rcs_data, w_vippa_mil_my)
rcs_data_r2 <- rcs_data_cr %>%
dplyr::filter(t_rebels == 1)
rcs_data_r2 <- rcs_data %>%
dplyr::filter(t_rebels == 1)
w_vippa_mil_my <- w_vippa_mil_my %>%
rename(divipola = mun)
rm(vippa, vippa_mil, vippa_mil_my)
rm(w_vippa_mil_my)
vippa <- read.dta13("ViPPA_v1_2.dta")
vippa_mil <- vippa %>%
filter(actor_main == "Paramilitaries")
vippa_mil <- vippa_mil %>%
filter(year < 2006)
vippa_mil %>%
group_by(actor_sub, actor) %>%
count()
vippa_mil_my <- vippa_mil %>%
group_by(mun, year, actor_sub) %>%
summarise(reports = n(), na.rm = TRUE)
w_vippa_mil_my <- spread(vippa_mil_my, actor_sub, reports)
w_vippa_mil_my <- w_vippa_mil_my %>%
dplyr::select(-c(na.rm, presence)) # It does not yield any result
w_vippa_mil_my <- w_vippa_mil_my %>%
rename(mil_gen = "Para. Generic",
soc_cl = "Social cleansing",
indep = "Independent_(310)")
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate_at(vars(mil_gen:indep)
, ~replace_na(., 0))
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate(c_mil_gen = if_else(mil_gen > 1, 1, 0), # This is to maintain the selection criterion of the dataset
d_mil_gen = if_else(mil_gen > 0, 1, 0),
d_AUC = if_else(AUC > 0, 1, 0),
d_ERPAC = if_else(ERPAC > 0, 1, 0),
d_AGC = if_else(AGC > 0, 1, 0),
d_ACC = if_else(ACC > 0, 1, 0),
d_ACCU = if_else(ACCU > 0, 1, 0),
d_soc_cl = if_else(soc_cl > 0, 1, 0),
d_indep = if_else(indep > 0, 1, 0)
)
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate(cr_v3 = case_when( # This is with the criterion!!!
c_mil_gen == 1 & d_AUC == 0 & d_ERPAC == 0 & d_AGC == 0
& d_ACCU == 0 & d_ACC == 0 ~ 1,
d_AUC == 1 | d_ERPAC == 1 | d_AGC == 1 | d_ACCU == 1 |
d_ACC == 1 ~ 0,
TRUE ~ 0))
w_vippa_mil_my <- w_vippa_mil_my %>%
mutate(cr_v2 = case_when(
d_mil_gen == 1 & d_AUC == 0 & d_ERPAC == 0 & d_AGC == 0
& d_ACCU == 0 & d_ACC == 0 ~ 1,
d_AUC == 1 | d_ERPAC == 1 | d_AGC == 1 | d_ACCU == 1 |
d_ACC == 1 ~ 0,
TRUE ~ 0))
w_vippa_mil_my %>%
group_by(cr_v3) %>%
count()
w_vippa_mil_my <- w_vippa_mil_my %>%
rename(divipola = mun)
cdaw_iv <- left_join(rcs_data_r, w_vippa_mil_my)
cdaw_iv <- cdaw_iv %>%
mutate_at(vars(mil_gen:cr_v2)
, ~replace_na(., 0))
cdaw_iv <- cdaw_iv %>%
rename(vc_param = cr_v3)
cdaw_iv <- cdaw_iv %>%
mutate(v_strat2 = case_when(
v_strat == 1 | vc_param == 1 ~ 1,
v_strat == 0 & vc_param == 0 ~ 0
))
cdaw_iv <- cdaw_iv %>%
dplyr::relocate(coddepto:year, p_strat:v_strat, v_strat2)
cdaw_iv <- cdaw_iv %>%
dplyr::relocate(divipola:year, p_strat:v_strat, v_strat2)
cdaw_iv %>%
group_by(p_strat) %>%
count()
cdaw_iv <- cdaw_iv %>%
mutate(r_cum2 = v_strat2 + s_strat + p_strat,
cr2 = if_else(r_cum2 > 0, 1, 0),
r_cum = v_strat + s_strat + p_strat,
cr = if_else(r_cum > 0, 1, 0))
cdaw_iv <- cdaw_iv %>%
dplyr::relocate(coddepto:year, p_strat:v_strat, v_strat2, r_cum2:cr)
cdaw_iv <- cdaw_iv %>%
dplyr::relocate(divipola:year, p_strat:v_strat, v_strat2, r_cum2:cr)
cdaw_iv <- cdaw_iv %>%
mutate(r_strat = case_when(
v_strat == 1 ~ 3, # V
s_strat == 1 & v_strat == 0 ~ 2, # S
p_strat == 1 & v_strat == 0 & s_strat == 0 ~ 1, # P
p_strat == 0 & v_strat == 0 & s_strat == 0 ~ 0, # NR
))
cdaw_iv <- cdaw_iv %>%
mutate(r_strat2 = case_when(
v_strat2 == 1 ~ 3, # V
s_strat == 1 & v_strat2 == 0 ~ 2, # S
p_strat == 1 & v_strat2 == 0 & s_strat == 0 ~ 1, # P
p_strat == 0 & v_strat2 == 0 & s_strat == 0 ~ 0, # NR
))
cdaw_iv %>%
group_by(r_strat) %>%
count()
review %>%
group_by(p_s_v2) %>%
count()
############################################
review <- cdaw_iv %>%
mutate(p_s = case_when(
p_strat == 1 & s_strat == 1 ~ 1,
TRUE ~ 0),
p_v = case_when(
p_strat == 1 & v_strat == 1 ~ 1,
TRUE ~ 0),
p_v2 = case_when(
p_strat == 1 & v_strat2 == 1 ~ 1,
TRUE ~ 0),
s_v = case_when(
s_strat == 1 & v_strat == 1 ~ 1,
TRUE ~ 0),
s_v2 = case_when(
s_strat == 1 & v_strat2 == 1 ~ 1,
TRUE ~ 0)
)
review <- cdaw_iv %>%
mutate(p_s_v = case_when(
p_strat == 1 & s_strat == 1 & v_strat ~ 1,
TRUE ~ 0),
p_s_v2 = case_when(
p_strat == 1 & s_strat == 1 & v_strat2 ~ 1,
TRUE ~ 0))
review %>%
group_by(p_s_v2) %>%
count()
View(cdaw_iv)
write_xlsx(cdaw_iv, "Ortega(2024)-IV-ResistanceStrategy(1985-2005).xlsx")
